﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using BlogApp.Data.Annotations;
using Newtonsoft.Json;

namespace BlogApp.Data.Models
{


    public class PostResult : INotifyPropertyChanged
    {

        [JsonProperty("status")]
        public string Status { get; set; }

        [JsonProperty("count")]
        public int Count { get; set; }

        [JsonProperty("count_total")]
        public int CountTotal { get; set; }

        [JsonProperty("pages")]
        public int Pages { get; set; }


        private ObservableCollection<Post> _posts;

        [JsonProperty("posts")]
        public ObservableCollection<Post> Posts
        {
            get { return _posts; }
            set { _posts = value; RaisePropertyChanged("Posts"); }
        }


        //public List<Post> Posts { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
